# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=iozone
pkgver=3.493
_pkgver=${pkgver//./_}
pkgrel=0
pkgdesc="IOzone filesystem benchmark."
url="http://iozone.org"
arch="all !riscv64"
license="custom"
options="!check" # No test suite from upstream
subpackages="$pkgname-doc"
source="http://iozone.org/src/current/iozone$_pkgver.tgz
	https://www.iozone.org/docs/Iozone_License.txt
	"
builddir="$srcdir/${pkgname}$_pkgver/"

build() {
	local target=
	case "$CARCH" in
		x86_64) target="linux-AMD64" ;;
		x86) target="linux" ;;
		aarch64) target="linux-arm" ;;
		armv7) target="linux-arm" ;;
		armhf) target="linux-arm" ;;
		s390x) target="linux-S390X" ;;
		ppc64le) target="linux-powerpc64" ;;
		*) msg "Unable to determine architecture from (CARCH=$CARCH)" ; return 1 ;;
	esac

	cd "$builddir"/src/current/
	make $target CFLAGS='-DHAVE_PREADV -DHAVE_PWRITEV'
}

package() {
	install -m755 -D src/current/iozone \
		"$pkgdir"/usr/bin/iozone

	install -Dm644 "$srcdir"/Iozone_License.txt \
		"$pkgdir"/usr/share/licenses/$pkgname/Iozone_License.txt

	install -Dm644 "$builddir"/docs/iozone.1 \
		"$pkgdir"/usr/share/man/man1/iozone.1
}

sha512sums="
89e41b8344f593cdf049c195a8b78468b3a59dcca3d0932e33feed15c02b4a15e290b5fca3c28a5490cc3d40009aa8c96093bb814cfb18a99bece4b3bb9ba8c8  iozone3_493.tgz
9589952c15cde6701f239b6031996e504fd62f70ef1e63938544ca8ecf7e38b53ff731919e48285a9354080120b74fcdd9d548ada9a719368726e67b536e6fda  Iozone_License.txt
"
